<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
    <title>X Axis Label Formatting</title>
    <!--[if IE]>
    <script type="text/javascript" src="../excanvas.js"></script>
    <![endif]-->
    <!--
    For production (minified) code, use:
    <script type="text/javascript" src="dygraph-combined.js"></script>
    -->
    <script type="text/javascript" src="../dygraph-dev.js"></script>

  </head>
  <body>
    <p>Original data:</p>
    <div id="normal" style="width:600px; height:300px;"></div>

    <p>Same data, but offset by 2 hours with the date formatter:</p>
    <div id="offby2" style="width:600px; height:300px;"></div>

    <p>Same data, but always displaying HH:MM:SS:</p>
    <div id="seconds" style="width:600px; height:300px;"></div>

    <script type="text/javascript">
      function HourlyData() {
        return "" +
          "Date,A,B\n" +
          "2009/07/12 00:00:00,3,4\n" +
          "2009/07/12 01:00:00,5,6\n" +
          "2009/07/12 02:00:00,7,6\n" +
          "2009/07/12 03:00:00,6,5\n" +
          "2009/07/12 04:00:00,4,7\n" +
          "2009/07/12 05:00:00,3,6\n" +
          "2009/07/12 06:00:00,4,6"
      }

      var g1 = new Dygraph(
            document.getElementById("normal"),
            HourlyData()
          );

      var g2 = new Dygraph(
            document.getElementById("offby2"),
            HourlyData(),
            { 
              axes: {
                x: {
                  axisLabelFormatter: function(d, gran) {
                      return Dygraph.dateAxisFormatter(new Date(d.getTime() + 7200*1000), gran);
                  }
                }
              }
            });

      var g3 = new Dygraph(
            document.getElementById("seconds"),
            HourlyData(),
            { 
              xAxisLabelWidth: 70,
              axes: {
                x: {
                  axisLabelFormatter: function(d, gran) {
                    return Dygraph.zeropad(d.getHours()) + ":"
                        + Dygraph.zeropad(d.getMinutes()) + ":"
                        + Dygraph.zeropad(d.getSeconds());
                  }
                }
              }
            });
    </script>
  </body>
</html>
